package BOM;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.JFrame;
import javax.swing.WindowConstants;

import BOM.MASTER.c_master;
import BOM.MASTER.m_master;
import TOOLS.SQLtool;

public class test001 {
	public static void main(String[] args) {
		SQLtool sql=new SQLtool();
		String IPaddr="192.168.1.1";
		try {
			InetAddress addr = InetAddress.getLocalHost();
			IPaddr=addr.getHostAddress();
		} catch (UnknownHostException e1) {
			;
		}
		sql.config(IPaddr, "AKS2019", "sa", "123456","test211126006");
//		sql.config("192.168.2.3", "AKS2021", "ma", "123456","testBOM230804");//172.16.3.115
		sql.config("172.16.3.115", "AKS2021", "ma", "123456","testBOM230804");//
		try {
			JFrame j=new JFrame();
			j.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
			j.setVisible(true);
			j.setLocation(-800, 0);
			sql.connect();
			
			c_master cm=new c_master(sql);
			m_master ibom= cm.getBinMaster("990368","V02","1");
			System.out.println(ibom.toString());
			
			
			j.dispose();
//			System.exit(0);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static String GetTimestamp() {
		// "2017-12-10 15:52:10";
		String timestamp = new String();
		SimpleDateFormat t = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
		timestamp = "" + t.format(new Date());
		return timestamp;
	}
	
	public static long getDiffMS(String iStartT, String iEndT) {
		SimpleDateFormat t = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
		try {
			Date s = t.parse(iStartT);
			Date e = t.parse(iEndT);
			long diff = e.getTime() - s.getTime();
			if (diff < 0) {
				diff = diff * (-1);
			}
			return diff;
		} catch (ParseException e1) {
			e1.printStackTrace();
		}
		return -1;
	}

}
